﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="Areas.aspx.cs" Inherits="Admin.Admin.Areas" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<script type="text/javascript">

function confirmAction() {
    if(confirm('Bạn có chắc chắn muốn xóa???')) {
        // you clicked the OK button.
        // you can allow the form to post the data.
        return true;
    }
    else {
      
       
        // you clicked the Cancel button.
        // you can disallow the form submission.
        return false;
    }
}

    function alertAction() {
    alert('Bạn phải xóa những tin thuộc khu vực này trước !!!') ;
  
}


    </script>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="Panel1" runat="server">
                <div class="dashboard">
                    <h2 class="ico_mug">
                        Danh sách Quận Huyện
                    </h2>
                    <div>
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                            DataKeyNames="AreaID" DataSourceID="ObjectDataSource1" ForeColor="#333333" GridLines="None"
                            Width="100%" AllowPaging="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <RowStyle BackColor="#EFF3FB" />
                            <Columns>
                                <asp:CommandField ButtonType="Image" SelectImageUrl="~/Admin/img/edit.png" 
                                    ShowSelectButton="True" >
                                    <ItemStyle Width="70px" />
                                </asp:CommandField>
                                <asp:BoundField DataField="AreaID" HeaderText="Mã khu vực" InsertVisible="False"
                                    ReadOnly="True" SortExpression="AreaID">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" Width="170px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="AreaName" HeaderText="Tên khu vực" SortExpression="AreaName">
                                    <HeaderStyle HorizontalAlign="Left" />
                                    <ItemStyle HorizontalAlign="Left" Width="200px" />
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="Kích hoạt">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="cbIsActive" runat="server" Checked='<%# Eval("IsActive") %>' 
                                            Enabled="False" />
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:TemplateField>
                            </Columns>
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#2461BF" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAreaBOList_byPaging"
                            TypeName="HousingInfo.Library.AreaBOList" EnablePaging="True" 
                            SelectCountMethod="GetTotal_AdminAreas"></asp:ObjectDataSource>
                        <br />
                        <asp:Label ID="messagedelete" runat="server" Font-Bold="True" 
                            Font-Size="Medium" ForeColor="#FF3300"></asp:Label>
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="PanelActions" runat="server">
                <div class="dashboard">
                    <h2 class="ico_mug">
                        &nbsp;<asp:Label ID="lbHeaderActions" runat="server" Text="Khu vực"></asp:Label>
                    </h2>
                    <div>
                        <table style="width: 100%">
                            <tr>
                                <td style="width: 84px">
                                    &nbsp;
                                </td>
                                <td style="width: 215px">
                                    <asp:Label ID="message" runat="server" Font-Bold="True" Font-Size="Medium" ForeColor="#FF3300"></asp:Label>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px; text-align: right;">
                                    <asp:Label ID="lbareaid" runat="server" Text="Mã Khu vực :"></asp:Label>
                                </td>
                                <td style="width: 215px">
                                    <asp:TextBox ID="txtareaid" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                                <td style="text-align: left">
                                    <asp:Label ID="lbHeaderActions0" runat="server" Font-Bold="True" Font-Names="Arial Unicode MS"
                                        Font-Size="Medium" Text="Khu vực chi tiết"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px; text-align: right;">
                                    <asp:Label ID="Label2" runat="server" Text="Tên Khu vực :"></asp:Label>
                                </td>
                                <td style="width: 215px">
                                    <asp:TextBox ID="txtareaname" runat="server" MaxLength="50"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtareaname"
                                        ErrorMessage="?" ValidationGroup="1"></asp:RequiredFieldValidator>
                                </td>
                                <td style="border-style: double; text-align: left;">
                                    &nbsp;<asp:ImageButton ID="btnImageAddAreaDetail" runat="server" ImageUrl="~/Admin/img/add.png"
                                        OnClick="btnImageAddAreaDetail_Click" CausesValidation="False" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    <asp:ImageButton ID="btnImageEditAreaDetail" runat="server" ImageUrl="~/Admin/img/edit.png"
                                        ToolTip="Edit" OnClick="btnImageEditAreaDetail_Click" CausesValidation="False" />
                                    &nbsp;&nbsp;&nbsp;
                                    <asp:ImageButton ID="btnImageDelAreaDetail" runat="server" ImageUrl="~/Admin/img/cancel.png"
                                        ToolTip="Delete" OnClientClick="javascript:return confirmAction();" OnClick="btnImageDelAreaDetail_Click1"
                                        CausesValidation="False" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px; height: 4px;">
                                    &nbsp;
                                </td>
                                <td style="width: 215px; height: 4px;">
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="txtareaname"
                                        ErrorMessage="Độ dài tối đa 50 ký tự" ValidationExpression="^([\S\s]{1,50})$"
                                        ValidationGroup="1"></asp:RegularExpressionValidator>
                                    <br />
                                </td>
                                <td align="left" dir="rtl" rowspan="5" style="vertical-align: top; text-align: left;">
                                    <asp:ListBox ID="listAreaDetail" runat="server" DataTextField="AreaDetailName" DataValueField="AreaDetailID"
                                        Height="201px" Style="margin-right: 52px" Width="92%"></asp:ListBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px; height: 4px; text-align: right;">
                                    <asp:Label ID="Label3" runat="server" Text="Kích hoạt :"></asp:Label>
                                </td>
                                <td style="width: 215px; height: 4px;">
                                    <asp:CheckBox ID="isActive" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px;">
                                </td>
                                <td style="width: 215px;">
                                    <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Cập nhật"
                                        ValidationGroup="1" />
                                    &nbsp;
                                    <asp:Button ID="btnDel" runat="server" OnClick="btnDel_Click" OnClientClick="javascript:return confirmAction();"
                                        Text="Xóa" CausesValidation="False" />
                                    <asp:Button ID="btnAdd" runat="server" OnClick="btnAdd_Click" Text="Thêm" ValidationGroup="1" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px; height: 9px;">
                                </td>
                                <td style="height: 9px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 84px">
                                    &nbsp;
                                </td>
                                <td style="width: 215px">
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel ID="PanelAreaDetail" runat="server" Visible="False">
                <div class="dashboard">
                    <h2 class="ico_mug">
                        &nbsp;<asp:Label ID="lbAreaDetail" runat="server" Text="Khu vực chi tiết"></asp:Label>
                    </h2>
                    <div>
                        <table style="width: 100%">
                            <tr>
                                <td style="width: 120px">                                    
                                </td>
                                <td style="width: 20px">
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Label ID="messagedetail" runat="server" Font-Bold="True" Font-Size="Medium"
                                        ForeColor="#FF3300"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 120px; text-align: right;">
                                    <asp:Label ID="lbAreaDetailID" runat="server" Text="Mã Khu vực chi tiết :"></asp:Label>
                                </td>
                                <td style="width: 20px">
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAreaDetailID" runat="server" Enabled="False"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 120px; text-align: right;">
                                    <asp:Label ID="Label5" runat="server" Text="Tên Khu vực chi tiết :"></asp:Label>
                                </td>
                                <td style="width: 20px">
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAreaDetailName" runat="server" MaxLength="50"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAreaDetailName"
                                        ErrorMessage="?" ValidationGroup="2"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtAreaDetailName"
                                        ErrorMessage="Độ dài tối đa 50 ký tự" ValidationExpression="^([\S\s]{1,50})$"
                                        ValidationGroup="2"></asp:RegularExpressionValidator>
                                </td>
                            </tr>
                           
                            <tr>
                                <td style="width: 120px; text-align: right;">
                                <asp:Label ID="Label1" runat="server" Text="Kích hoạt :"></asp:Label>
                                </td>
                                <td style="width: 20px">
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:CheckBox ID="isActiveAreaDetail" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 120px; text-align: right;">
                                    &nbsp;</td>
                                <td style="width: 20px">
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Button ID="btnUpdateDetail" runat="server" OnClick="btnUpdateDetail_Click" 
                                        Text="Cập nhật" ValidationGroup="2" />
                                    &nbsp;
                                    <asp:Button ID="btnAddDetail" runat="server" OnClick="btnAddDetail_Click" 
                                        Text="Thêm" ValidationGroup="2" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    </asp:Content>
